<template>
  <div class="file-log">
    <!-- 部门数据
      <el-col :span="4" :xs="24">
        <div style="margin-top: 20px">
          <el-input
            v-model="deptName"
            placeholder="请输入部门名称"
            clearable
            size="small"
            prefix-icon="el-icon-search"
            style="margin-bottom: 20px"
          />
        </div>
        <div class="head-container"></div>
      </el-col> -->
    <!-- 用户数据 -->
    <el-col :span="22">
      <!-- 搜索 -->
      <el-form
        size="small"
        :inline="true"
        v-show="showSearch"
        @submit.native.prevent
        style="margin-top: 18px"
      >
        <el-form-item label="">
          <el-input
            v-model="keyword"
            placeholder="输入文档名或上传人姓名"
            clearable
            style="width: 240px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuery"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
      <!-- 表格 -->
      <el-table
        :data="
          fileData.slice((currentPage1 - 1) * pageSize, currentPage1 * pageSize)
        "
        :header-cell-style="{
          color: '#515a6e',
          'font-size': '15px',
          background: '#f8f8f9',
        }"
        @sort-change="sortChange"
        :cell-style="{ padding: '9px' }"
        style="width: 100%; margin-left: 50px"
      >
        <el-table-column
          prop="fileName"
          label="文档名"
          align="center"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          prop="fileId"
          label="文档ID"
          align="center"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          prop="browseNum"
          label="总浏览次数"
          align="center"
          sortable="custom"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          prop="downloadNum"
          label="总下载次数"
          align="center"
          sortable="custom"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column prop="createName" label="上传人" align="center">
        </el-table-column>
        <el-table-column
          prop="createTime"
          label="上传日期"
          align="center"
          sortable="custom"
        >
        </el-table-column>
        <el-table-column
          label="操作"
          align="center"
          width="200px"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <!-- 点击详情跳转 -->
            <el-button
              @click="onFileDetails(scope.$index, fileData)"
              type="text"
              size="mini"
              icon="el-icon-s-data"
              >详情</el-button
            >
            <el-button 
              v-if="scope.row.abandonReason == null"
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.$index, fileData)"
              >下架&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </el-button>
            <!-- <el-button 
              v-if="fileData.fileType == -1 && scope.row.abandonReason == null"
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.$index, fileData)"
              >已下架&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </el-button> -->
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              v-if="scope.row.abandonReason != null"
              @click="showDelete(scope.$index, fileData)"
              >下架信息</el-button
            >
            <el-dropdown
              size="mini"
              @command="(command) => handleCommand(command, scope.row)"
              style="cursor: pointer"
            >
              <span class="el-dropdown-link">
                <i class="el-icon-d-arrow-right el-icon--right"></i>更多
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="handleBrowse" icon="el-icon-view"
                  >浏览日志</el-dropdown-item
                >
                <el-dropdown-item
                  command="handleDownload"
                  icon="el-icon-download"
                  >下载日志</el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <div class="main-pagination">
        <el-pagination
          style="float: right; margin-top: 20px"
          background
          prev-text="<"
          next-text=">"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange1"
          :current-page="currentPage1"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="fileData.length"
        >
        </el-pagination>
      </div>
    </el-col>
    <!-- 下架对话框 -->
    <el-dialog
      class="deleteFile"
      :visible.sync="deleteVisible"
      :show-close="false"
      :modal-append-to-body="false"
    >
      <img src="@/assets/image/manage/warn.png" /><br /><br />
      <p style="font-size: 25px; font-weight: bolder; color: black">
        您确认要下架该文档吗?
      </p>
      <p
        style="
          font-size: 25px;
          font-weight: bolder;
          color: black;
          float: left;
          margin-left: 100px;
          margin-top: 30px;
        "
      >
        下架原因:
      </p>
      <div
        style="
          width: 550px;
          float: middle;
          margin: auto;
          position: absolute;
          left: 0;
          right: 0;
          margin-top: 80px;
        "
      >
        <el-input type="textarea" :rows="6" v-model="abandonReason" placeholder="必填"> </el-input>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="deleteF" class="btn-confirm-delete"
          >确 定</el-button
        >
        <el-button
          type="warning"
          @click="deleteVisible = false"
          class="btn-cancel-delete"
          >取 消</el-button
        >
      </span>
    </el-dialog>
    <!-- 文档详情对话框 -->
    <div class="docBox">
      <el-dialog title="文档详情" :visible.sync="detailsVisible" width="35%">
        <template>
          <el-descriptions class="margin-top" :column="2" size="">
            <el-descriptions-item label="文档名"
              ><el-tooltip :content="detailsData.fileName" placement="top">
                <span class="spanStyle1">{{ detailsData.fileName }}</span>
              </el-tooltip></el-descriptions-item
            >
            <el-descriptions-item label="上传人">{{
              detailsData.createName
            }}</el-descriptions-item>
            <el-descriptions-item label="文档id">{{
              detailsData.fileId
            }}</el-descriptions-item>
            <el-descriptions-item label="隶属部门">
              {{ detailsData.deptName }}
            </el-descriptions-item>
            <el-descriptions-item label="文档属性"
              ><span v-if="detailsData.fileType == 0">私有</span>
              <span v-if="detailsData.fileType == 1">公开(所有人可见)</span>
              <span v-if="detailsData.fileType == 2">公开(仅部分可见)</span>
              <span v-if="detailsData.fileType == -1"
                >已下架</span
              ></el-descriptions-item
            >
            <el-descriptions-item label="部门负责人">
              {{ detailsData.leaderName }}
            </el-descriptions-item>
            <el-descriptions-item label="下载总次数">
              {{ detailsData.downloadNum }}
            </el-descriptions-item>
            <el-descriptions-item label="浏览总次数">
              {{ detailsData.browseNum }}
            </el-descriptions-item>
            <el-descriptions-item label="今日下载次数">
              {{ detailsData.downloadNum1 }}
            </el-descriptions-item>
            <el-descriptions-item label="今日浏览次数">
              {{ detailsData.browseNum1 }}
            </el-descriptions-item>
            <el-descriptions-item label="7日内下载次数">
              {{ detailsData.downloadNum7 }}
            </el-descriptions-item>
            <el-descriptions-item label="7日内浏览次数">
              {{ detailsData.browseNum7 }}
            </el-descriptions-item>
            <el-descriptions-item label="30日内下载次数">
              {{ detailsData.downloadNum30 }}
            </el-descriptions-item>
            <el-descriptions-item label="30日内浏览次数">
              {{ detailsData.browseNum30 }}
            </el-descriptions-item>
            <el-descriptions-item label="上传时间">
              {{ detailsData.createTime }}
            </el-descriptions-item>
            <el-descriptions-item label="下架时间">
              {{ detailsData.abandonTime }}
            </el-descriptions-item>
          </el-descriptions>
          <!-- <el-form label-position="right" label-width="120px">
            <el-row>
              <el-col :span="12">
                <el-form-item label="文档名">
                  <el-tooltip :content="detailsData.fileName" placement="top">
                    <span class="spanStyle1">{{ detailsData.fileName }}</span>
                  </el-tooltip>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="上传人">
                  {{ detailsData.createName }}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="文档id">
                  {{ detailsData.fileId }}
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="隶属部门">
                  {{ detailsData.deptName }}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="文档属性">
                  <span v-if="detailsData.fileType == 0">私有</span>
                  <span v-if="detailsData.fileType == 1">公开(所有人可见)</span>
                  <span v-if="detailsData.fileType == 2">公开(仅部分可见)</span>
                  <span v-if="detailsData.fileType == -1">已下架</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="部门负责人">
                  {{ detailsData.leaderName }}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="下载总次数">
                  {{ detailsData.downloadNum }}
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="浏览总次数">
                  {{ detailsData.browseNum }}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="今日下载次数">
                  {{ detailsData.downloadNum1 }}
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="今日浏览次数">
                  {{ detailsData.browseNum1 }}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="7日内下载次数">
                  {{ detailsData.downloadNum7 }}
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="7日内浏览次数">
                  {{ detailsData.browseNum7 }}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="30日内下载次数">
                  {{ detailsData.downloadNum30 }}
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="30日内浏览次数">
                  {{ detailsData.browseNum30 }}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="上传时间">
                  {{ detailsData.createTime }}
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="下架时间">
                  {{ detailsData.abandonTime }}
                </el-form-item>
              </el-col>
            </el-row>
          </el-form> -->
        </template>
      </el-dialog>
    </div>
    <!-- 下架详情对话框 -->
    <div class="abandonBox">
      <el-dialog title="下架详情" :visible.sync="abandonVisible" width="30%">
        <template>
          <el-form label-position="right" label-width="100px">
            <el-form-item label="下架操作人">
              {{ detailsData.abandonName }}
            </el-form-item>
            <el-form-item label="隶属部门">
              {{ detailsData.abandonDept }}
            </el-form-item>
            <el-form-item label="下架原因">
              <el-tooltip
                class="item"
                effect="dark"
                :content="detailsData.abandonReason"
                placement="bottom"
                ><span class="spanStyle">{{ detailsData.abandonReason }}</span>
              </el-tooltip>
            </el-form-item>
          </el-form>
        </template>
      </el-dialog>
    </div>
    <!-- 浏览日志对话框 -->
    <div class="tableDialog">
      <el-dialog title="浏览日志" :visible.sync="browseVisible" width="50%">
        <template>
          <!-- 搜索 -->
          <el-form size="small" :inline="true" @submit.native.prevent>
            <el-form-item label="">
              <el-input
                v-model="keyword1"
                placeholder="输入人名、部门或时间"
                clearable
                style="width: 240px"
                @keyup.enter.native="searchBrowse"
              />
            </el-form-item>
            <el-form-item>
              <el-button
                type="primary"
                icon="el-icon-search"
                size="mini"
                @click="searchBrowse"
                >搜索</el-button
              >
            </el-form-item>
          </el-form>
          <!-- 浏览人表格 -->
          <div>
            <el-table
              :data="browseData.slice((currentPage2 - 1) * 5, currentPage2 * 5)"
              @sort-change="sortChange1"
              stripe
              style="width: 100%"
            >
              <el-table-column prop="name" label="浏览人" align="center">
              </el-table-column>
              <el-table-column prop="dept" label="隶属部门" align="center">
              </el-table-column>
              <el-table-column prop="leader" label="部门负责人" align="center">
              </el-table-column>
              <el-table-column
                prop="time"
                label="浏览时间"
                align="center"
                sortable="custom"
              >
              </el-table-column>
            </el-table>
          </div>
          <!-- 分页 -->
          <div class="table-pagination">
            <el-pagination
              prev-text="上一页"
              next-text="下一页"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange2"
              :current-page="currentPage2"
              :page-size="5"
              layout="prev, next"
              :total="browseData.length"
            >
            </el-pagination>
          </div>
        </template>
      </el-dialog>
    </div>
    <!-- 下载日志对话框 -->
    <div class="tableDialog">
      <el-dialog title="下载日志" :visible.sync="downloadVisible" width="50%">
        <template>
          <!-- 搜索 -->
          <el-form size="small" :inline="true" @submit.native.prevent>
            <el-form-item label="">
              <el-input
                v-model="keyword2"
                placeholder="输入人名、部门或时间"
                clearable
                style="width: 240px"
                @keyup.enter.native="searchDownload"
              />
            </el-form-item>
            <el-form-item>
              <el-button
                type="primary"
                icon="el-icon-search"
                size="mini"
                @click="searchDownload"
                >搜索</el-button
              >
            </el-form-item>
          </el-form>
          <!-- 下载人表格 -->
          <div>
            <el-table
              :data="
                downloadData.slice((currentPage3 - 1) * 5, currentPage3 * 5)
              "
              @sort-change="sortChange2"
              stripe
              style="width: 100%"
            >
              <el-table-column prop="name" label="下载人" align="center">
              </el-table-column>
              <el-table-column prop="dept" label="隶属部门" align="center">
              </el-table-column>
              <el-table-column prop="leader" label="部门负责人" align="center">
              </el-table-column>
              <el-table-column
                prop="time"
                label="下载时间"
                align="center"
                sortable="custom"
              >
              </el-table-column>
            </el-table>
          </div>
          <!-- 分页 -->
          <div class="table-pagination">
            <el-pagination
              prev-text="上一页"
              next-text="下一页"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange3"
              :current-page="currentPage3"
              :page-size="5"
              layout="prev, next"
              :total="downloadData.length"
            >
            </el-pagination>
          </div>
        </template>
      </el-dialog>
    </div>
  </div>
</template>
<script>
import {
  deleteFile,
  getFileData,
  getFileBrowseList,
  getFileDownloadList,
  searchFileData,
  searchDownloadData,
  searchBrowseData,
} from "@/api/manage/fileLog";
export default {
  data: function () {
    return {
      userId: this.$store.getters.userId,
      userName: this.$store.getters.userName,
      dept: this.$store.getters.userDept,
      getTime: "",
      fileId: undefined,
      keyword: undefined,
      keyword1: undefined,
      keyword2: undefined,
      deptName: undefined,
      showSearch: true,
      abandonReason: null,
      deleteVisible: false,
      abandonVisible: false,
      detailsVisible: false,
      browseVisible: false,
      downloadVisible: false,
      currentPage1: 1,
      currentPage2: 1,
      currentPage3: 1,
      pageSize: 10,
      fileData: [
        {
          fileName:
            "xx报表xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          fileId: "axd12138",
          browseNum: 165,
          downloadNum: 165,
          createName: "李四",
          deptName: "xx部门",
          leaderName: "张三",
          createTime: "2022-7-20 15:30:27",
          abandonTime: null,
          abandonReason: null,
        },
        {
          fileName:
            "xx报表xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          fileId: "axd12138",
          browseNum: 165,
          downloadNum: 165,
          createName: "李四",
          deptName: "xx部门",
          leaderName: "张三",
          createTime: "2022-7-20 15:30:27",
          abandonTime: null,
          abandonReason: null,
        },
        {
          fileName:
            "xx报表xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          fileId: "axd12138",
          browseNum: 165,
          downloadNum: 165,
          createName: "李四",
          deptName: "xx部门",
          leaderName: "张三",
          createTime: "2022-7-20 15:30:27",
          abandonTime: null,
          abandonReason: null,
        },
        {
          fileName:
            "xx报表xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          fileId: "axd12138",
          browseNum: 165,
          downloadNum: 165,
          createName: "李四",
          deptName: "xx部门",
          leaderName: "张三",
          createTime: "2022-7-20 15:30:27",
          abandonTime: null,
          abandonReason: null,
        },
        {
          fileName:
            "xx报表xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          fileId: "axd12138",
          browseNum: 165,
          downloadNum: 165,
          createName: "李四",
          deptName: "xx部门",
          leaderName: "张三",
          createTime: "2022-7-20 15:30:27",
          abandonTime: null,
          abandonReason: null,
        },
        {
          fileName:
            "xx报表xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          fileId: "axd12138",
          browseNum: 165,
          downloadNum: 165,
          createName: "李四",
          deptName: "xx部门",
          leaderName: "张三",
          createTime: "2022-7-20 15:30:27",
          abandonTime: null,
          abandonReason: null,
        },
        {
          fileName:
            "xx报表xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          fileId: "axd12138",
          browseNum: 165,
          downloadNum: 165,
          createName: "李四",
          deptName: "xx部门",
          leaderName: "张三",
          createTime: "2022-7-20 15:30:27",
          abandonTime: null,
          abandonReason: null,
        },
        {
          fileName:
            "xx报表xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          fileId: "axd12138",
          browseNum: 165,
          downloadNum: 165,
          createName: "李四",
          deptName: "xx部门",
          leaderName: "张三",
          createTime: "2022-7-20 15:30:27",
          abandonTime: null,
          abandonReason: null,
        },
        {
          fileName:
            "xx报表xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          fileId: "axd12138",
          browseNum: 165,
          downloadNum: 165,
          createName: "李四",
          deptName: "xx部门",
          leaderName: "张三",
          createTime: "2022-7-20 15:30:27",
          abandonTime: null,
          abandonReason: null,
        },
        {
          fileName:
            "xx报表xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          fileId: "axd12138",
          browseNum: 165,
          downloadNum: 165,
          createName: "李四",
          deptName: "xx部门",
          leaderName: "张三",
          createTime: "2022-7-20 15:30:27",
          abandonTime: null,
          abandonReason: null,
        },
        {
          fileName: "oo报表",
          fileId: "axd12137",
          browseNum: 15,
          downloadNum: 1565,
          createName: "李明",
          deptName: "xx部门",
          leaderName: "王红",
          createTime: "2021-7-20 15:30:27",
          abandonTime: "2021-7-20 15:30:27",
          abandonReason:
            "菜!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
          abandonDept: "xx部门",
          abandonName: "白",
        },
      ],
      detailsData: {
        fileId: "",
        abandonReason: null,
        abandonDept: null,
        abandonTime: null,
      },
      browseData: [
        {
          userId: 1,
          name: "王五",
          dept: "xxx部门",
          leader: "白某",
          time: "2021-7-20  18:06:13",
        },
        {
          userId: 1,
          name: "王五",
          dept: "xxx部门",
          leader: "白某",
          time: "2021-7-20  18:06:13",
        },
        {
          userId: 1,
          name: "王五",
          dept: "xxx部门",
          leader: "白某",
          time: "2021-7-20  18:06:13",
        },
        {
          userId: 1,
          name: "王五",
          dept: "xxx部门",
          leader: "白某",
          time: "2021-7-20  18:06:13",
        },
        {
          userId: 1,
          name: "王五",
          dept: "xxx部门",
          leader: "白某",
          time: "2021-7-20  18:06:13",
        },
        {
          userId: 1,
          name: "王五",
          dept: "xxx部门",
          leader: "白某",
          time: "2021-7-20  18:06:13",
        },
        {
          userId: 1,
          name: "王五",
          dept: "xxx部门",
          leader: "白某",
          time: "2021-7-20  18:06:13",
        },
        {
          userId: 1,
          name: "王五",
          dept: "xxx部门",
          leader: "白某",
          time: "2021-7-20  18:06:13",
        },
      ],
      downloadData: [
        {
          userId: 1,
          name: "王五",
          dept: "xxx部门",
          leader: "白某",
          time: "2021-7-20  18:06:13",
        },
      ],
    };
  },
  created: function () {
    getFileData()
      .then((res) => {
        this.fileData = res.data;
        console.log(this.fileData);
      })
      .catch((e) => {
        console.log(e);
      });
  },
  methods: {
    //搜索浏览人
    searchBrowse() {
      let data = {
        keyword: this.keyword1,
        fileId: this.fileId,
      };
      searchBrowseData(data)
        .then((res) => {
          let value = res.code;
          if (value == 200) {
            this.browseData = res.data;
          }
        })
        .catch((e) => {
          this.$message({
            type: "error",
            message: "搜索失败",
          });
          console.log(e);
        });
    },
    //搜索下载人
    searchDownload() {
      let data = {
        keyword: this.keywor2,
        fileId: this.fileId,
      };
      // axios
      searchDownloadData(data)
        .then((res) => {
          let value = res.code;
          if (value == 200) {
            this.downloadData = res.data;
          }
        })
        .catch((e) => {
          this.$message({
            type: "error",
            message: "搜索失败",
          });
          console.log(e);
        });
    },
    //下架详情
    showDelete(index, rows) {
      index = (this.currentPage1 - 1) * this.pageSize + index;
      this.detailsData = rows[index];
      this.abandonVisible = true;
    },
    // 更多操作触发
    handleCommand(command, row) {
      switch (command) {
        case "handleBrowse":
          this.handleBrowse(row);
          break;
        case "handleDownload":
          this.handleDownload(row);
          break;
        default:
          break;
      }
    },
    // 浏览日志
    handleBrowse(row) {
      this.fileId = row.fileId;
      let data = {
        fileId: this.fileId,
      };
      console.log(data);
      // axios
      getFileBrowseList(data)
        .then((res) => {
          let value = res.code;
          if (value == 200) {
            this.browseData = res.data;
            console.log("成功");
          } else console.log("失败");
        })
        .catch((e) => {
          this.$message({
            type: "error",
            message: "未获取到详情",
          });
          console.log(e);
        });
      this.browseVisible = true;
    },
    // 下载日志
    handleDownload(row) {
      this.fileId = row.fileId;
      let data = {
        fileId: this.fileId,
      };
      console.log(data);
      getFileDownloadList(data)
        .then((res) => {
          let value = res.code;
          if (value == 200) {
            this.downloadData = res.data;
            console.log("成功");
          } else console.log("失败");
        })
        .catch((e) => {
          this.$message({
            type: "error",
            message: "未获取到详情",
          });
          console.log(e);
        });
      this.downloadVisible = true;
    },
    /** 查询用户列表 */
    getList() {
      let data = {
        keyword: this.keyword,
      };
      this.loading = true;
      searchFileData(data).then((res) => {
        this.fileData = res.data;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.currentPage1 = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.keyword = '';
      this.handleQuery();
    },
    //打开详情
    onFileDetails(index, rows) {
      index = (this.currentPage1 - 1) * this.pageSize + index;
      this.detailsData = rows[index];
      this.detailsVisible = true;
    },
    //下架文档 +-+
    handleDelete(index, rows) {
      index = (this.currentPage1 - 1) * this.pageSize + index;
      this.fileId = rows[index].fileId;
      this.deleteVisible = true;
    },
    deleteF() {
      this.getCurrentTime();
      let data = {
        abandonId: this.userId,
        abandonTime: this.getTime,
        abandonReason: this.abandonReason,
        fileId: this.fileId,
      };
      let body = JSON.stringify(data);
      console.log(body);
      // axios
      deleteFile(body)
        .then((res) => {
          let value = res.code;
          if (value == 200) {
            this.deleteVisible = false;
            this.$message({
              type: "success",
              message: "下架成功",
            });
          }
        })
        .catch((e) => {
          this.abandonReason = null;
          this.$message({
            type: "error",
            message: "下架文档失败",
          });
          console.log(e);
        });
      console.log("下架文档");
      //this.change();
    },
    // 每页多少条
    handleSizeChange(val) {
      this.pageSize = val;
    },
    // 当前页
    handleCurrentChange1(val) {
      this.currentPage1 = val;
    },
    handleCurrentChange2(val) {
      this.currentPage2 = val;
    },
    handleCurrentChange3(val) {
      this.currentPage3 = val;
    },
    sortChange({ prop, order }) {
      this.fileData.sort(this.compare(prop, order));
    },
    sortChange1({ prop, order }) {
      this.browseData.sort(this.compare(prop, order));
    },
    sortChange2({ prop, order }) {
      this.downloadData.sort(this.compare(prop, order));
    },
    compare(propertyName, sort) {
      return function (obj1, obj2) {
        var value1 = obj1[propertyName];
        var value2 = obj2[propertyName];
        if (typeof value1 === "string" && typeof value2 === "string") {
          const res = value1.localeCompare(value2, "zh");
          return sort === "ascending" ? res : -res;
        } else {
          if (value1 <= value2) {
            return sort === "ascending" ? -1 : 1;
          } else if (value1 > value2) {
            return sort === "ascending" ? 1 : -1;
          }
        }
      };
    },
    //获取时间
    getCurrentTime() {
      //获取当前时间并打印
      var _this = this;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let hh = new Date().getHours();
      let mf =
        new Date().getMinutes() < 10
          ? "0" + new Date().getMinutes()
          : new Date().getMinutes();
      let ss =
        new Date().getSeconds() < 10
          ? "0" + new Date().getSeconds()
          : new Date().getSeconds();
      _this.getTime = yy + "-" + mm + "-" + dd + " " + hh + ":" + mf + ":" + ss;
      console.log(_this.getTime);
    },
  },
};
</script>
<style lang="less">
.file-log {
  .main-pagination {
    position: absolute;
    bottom: 20px;
    right: 50px;
  }
  .table-pagination {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    .el-pagination .btn-next,
    .el-pagination .btn-prev {
      width: 100px;
      height: 29px;
      background: rgba(22, 155, 213, 1) !important;
      color: #fff !important;
      border: none;
      border-radius: 5px;
    }
    .el-pagination .btn-next {
      margin-left: 20px;
    }
  }
  .tableDialog {
    .el-dialog {
      height: 500px;
    }
  }
  .docBox {
    .el-form-item {
      margin-bottom: 15px;
    }
    .el-form-item__label {
      font-weight: bolder;
    }
    .el-form-item__content {
      text-align: left;
    }
  }
  .abandonBox {
    .el-form-item__label {
      font-weight: bolder;
    }
    .el-form-item__content {
      text-align: left;
      margin-left: 130px !important;
    }
  }
  .el-row {
    margin-left: 0px !important;
  }
  .el-dropdown {
    color: #409eff;
    font-size: 12px;
  }
  .deleteFile {
    .el-dialog {
      border: 4px solid orange;
      width: 800px;
      height: 500px;
      background-color: whitesmoke;
    }
    .el-dialog__header {
      padding: 0;
    }
    .el-dialog__footer {
      margin-top: 220px;
    }
  }
  .btn-cancel-delete {
    float: right !important;
    margin-right: 150px !important;
    margin-top: 20px !important;
    width: 120px !important;
    height: 40px !important;
    line-height: 5px !important;
    background-color: orange !important;
    color: white !important;
  }
  .btn-confirm-delete {
    margin-right: 200px !important;
    margin-top: 20px !important;
    width: 120px !important;
    height: 40px !important;
    line-height: 5px !important;
  }
}
</style>
<style scoped>
.spanStyle {
  display: inline-block;
  white-space: normal;
  width: 200px;
  overflow: hidden; /*超出的文本隐藏*/
  text-overflow: ellipsis; /* 溢出用省略号*/
}
.spanStyle1 {
  display: inline-block;
  width: 150px;
  overflow: hidden; /*超出的文本隐藏*/
  text-overflow: ellipsis; /* 溢出用省略号*/
  white-space: nowrap;
}
</style>
